<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
class ProductsApproval extends Model
{
    protected $table = 's_products_approval';
    protected $primaryKey = 'id';
    const UPDATED_AT = null;
    const CREATED_AT = null;

    protected $fillable = [
        'supplier_code',
        'product_code',
        'product_name',
        'generic_name',
        'pinyin_code',
        'specification',
        'unit',
        'origin',
        'manufacturer',
        'barcode',
        'certificate_category_id',
        'registration_number',
        'dosage_form',
        'package_unit',
        'component_unit',
        'package_specification',
        'component_unit_code',
        'component_specification',
        'preparation_unit_code',
        'business_category_code',
        'preparation_unit',
        'purchase_price',
        'sale_price',
        'creator_id',
        'create_time',
        'update_time',
    ];

    public function setProductsApproval($data)
    {
        return DB::table('s_products_approval')->insert($data);
    }

    public static function editApprovalStatus($where,$update)
    {

        return DB::table('s_products_approval')->where($where)->update($update);
    }

    public function getProductsApproval($where)
    {
        return DB::table('s_products_approval')->where($where)->get()->toArray();
    }

}
